﻿using System;
using System.Collections.Generic;
using Framework.Library.Base.Base;
using Framework.Library.Base.Extensions;
using Framework.Library.Core.Config;
using Framework.Library.Data.DAL;
using Framework.Library.Data.DAO;
using Framework.Library.Data.DAL.JObject;

namespace Framework.Portal.Layouts.Admin.Modules.Menus
{
    public partial class MainMenu : BaseControl
    {
        private readonly int parentId;
        public string MENUNAME = string.Empty;

        public MainMenu()
        {
        }

        public MainMenu(JSection section)
        {
            MENUNAME = section.title;
            parentId = Convert.ToInt32(section.parameter.Split('=')[1]);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadMenu();
        }

        private void LoadMenu()
        {
            ucMainMenu.parentMenu = parentId;
            List<PortalMenu> dtCommands = ManagerFactory.PortalMenuManager.GetAll(Configurations.PORTALID, Session.GetUser().USERID);
            if (dtCommands != null)
                ucMainMenu.DataSource = dtCommands;
        }
    }
}